package com.winning.bi.jdbc;

import org.apache.log4j.Logger;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.TriggerBuilder;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 
 * @author 张大川 生产者 负责产生数据，
 */
public class Producer {
	private static Logger log = Logger.getLogger(Producer.class);

	public static void main(String[] args) throws SchedulerException {
		log.info("[xxxxxXXXXXXXXXXXXXXXXXXXXXXXXXX]"+"");
		//JFrame frame= new JFrame("ETL");
		//Toolkit kit = Toolkit.getDefaultToolkit();
		
		
		ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("file:config/applicationContext.xml");
		Scheduler scheduler = (Scheduler) ac.getBean("schedulerFactoryBean");

		JobDetail jobDetail = JobBuilder.newJob(SqlJob.class).withIdentity("testJob_1", "group_1").build();
		jobDetail.getJobDataMap().put("ac", ac);
		//Date runTime = DateBuilder.evenSecondDateAfterNow();
		CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/10 * * * * ?"); 
		CronTrigger  trigger = TriggerBuilder.newTrigger().withIdentity("xxx", "yyy")  
	                .withSchedule(scheduleBuilder).build();  
		scheduler.scheduleJob(jobDetail, trigger);
		log.info("[xxxxx]"+"运行");
		//System.out.println(jobDetail.getKey() + " 运行在XXXXXXXXXXXXXXXXXXX: " + runTime);
		//scheduler.start();
	}

}
